package com.moonzero.ui;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.moonzero.service.ICustomerService;

/**
 * 配置测试
 *
 * @author MoonZero
 */
public class ClientTest {
    public static void main(String[] args) {
        // 获取spring容器操作对象
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        // 根据id获取对象
        ICustomerService cs = (ICustomerService) context.getBean("customerService");
        // 打印对象查看是否为代理对象
        System.out.println(cs.getClass().getName());

        // 要使用基于子类的，对象不能实现接口
        // CustomerServiceImpl cs = (CustomerServiceImpl) context.getBean("customerService");

        // 调用方法
        cs.saveCustomer();
        cs.updateCustomer(10);
    }
}
